package aes.client;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;


public class ReportPrincipalUI extends JPanel implements ActionListener{
	
private static final long serialVersionUID = 6743276532631154569L;
	
	private ClientUI ui;
	@SuppressWarnings("unused")
	private Client c;
	
	private JButton btnTeacherReport;
	private JButton btnStudentReport;
	private JButton btnCourseReport;
	private JButton btnBack;
	private JPanel panel_1;
	private JPanel panel_2;

	/**
	 * Constructor
	 * @param ui reference of parent frame
	 */ 
	public ReportPrincipalUI(Client c, ClientUI ui) {
		super();
		this.ui = ui;
		this.c = c;
	
		JFrame frame = new JFrame();
		frame.setSize(640, 480);
		frame.getContentPane().add(this);
		
		setLayout(new GridBagLayout());

		JPanel panel = new JPanel();
		panel.setBorder(new LineBorder(new Color(0, 0, 0), 2, true));
		panel.setPreferredSize(new Dimension(600,400));
		panel.setSize(new Dimension(600,400));
		
		GridBagConstraints gbc_panel = new GridBagConstraints();
		gbc_panel.insets = new Insets(5, 0, 5, 0);
		gbc_panel.gridx = 0;
		gbc_panel.gridy = 0;
		add(panel,gbc_panel);
		GridBagLayout gbl_panel = new GridBagLayout();
		gbl_panel.rowWeights = new double[]{0.0, 0.0, 1.0};
		gbl_panel.columnWeights = new double[]{1.0, 0.0, 0.0};
		panel.setLayout(gbl_panel);
		
		JLabel lblAesTitle = new JLabel("Reports:");
		lblAesTitle.setHorizontalAlignment(SwingConstants.CENTER);
		lblAesTitle.setVerticalAlignment(SwingConstants.TOP);
		lblAesTitle.setBounds(7, 10, 70, 17);
		lblAesTitle.setFont(new Font("Tahoma", Font.BOLD, 14));
		
		GridBagConstraints gbc_lblAesTitle = new GridBagConstraints();
		gbc_lblAesTitle.gridwidth = 3;
		gbc_lblAesTitle.fill = GridBagConstraints.BOTH;
		gbc_lblAesTitle.insets = new Insets(5, 0, 25, 0);
		gbc_lblAesTitle.gridx = 0;
		gbc_lblAesTitle.gridy = 0;
		panel.add(lblAesTitle, gbc_lblAesTitle);
		
		panel_1 = new JPanel();
		GridBagConstraints gbc_panel_1 = new GridBagConstraints();
		gbc_panel_1.insets = new Insets(30, 0, 0, 0);
		gbc_panel_1.fill = GridBagConstraints.BOTH;
		gbc_panel_1.gridx = 0;
		gbc_panel_1.gridy = 2;
		gbc_panel_1.gridwidth = 3;
		panel.add(panel_1, gbc_panel_1);
		panel_1.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
		
		btnTeacherReport = new JButton("Teacher Statistics");
		btnTeacherReport.setIcon(new ImageIcon(ReportPrincipalUI.class.getResource("/aes/client/images/teacher.png")));
		btnTeacherReport.addActionListener(this); 
		GridBagConstraints gbc_btnTeacherReport = new GridBagConstraints();
		gbc_btnTeacherReport.insets = new Insets(5, 5, 5, 5);
		panel_1.add(btnTeacherReport, gbc_btnTeacherReport);
		btnTeacherReport.setBounds(353, 7, 57, 23);
		
		btnCourseReport = new JButton("Course Statistics");
		btnCourseReport.setIcon(new ImageIcon(ReportPrincipalUI.class.getResource("/aes/client/images/lessons.png")));
		btnCourseReport.addActionListener(this); 
		GridBagConstraints gbc_btnCourseReport = new GridBagConstraints();
		gbc_btnCourseReport.insets = new Insets(5, 5, 5, 5);
		panel_1.add(btnCourseReport, gbc_btnCourseReport);
		btnCourseReport.setBounds(353, 7, 57, 23);
	
		btnStudentReport  = new JButton("Student Statistics");
		btnStudentReport.setIcon(new ImageIcon(ReportPrincipalUI.class.getResource("/aes/client/images/Student.png")));
		btnStudentReport.addActionListener(this); 
		GridBagConstraints gbc_btnStudentReport = new GridBagConstraints();
		gbc_btnStudentReport.insets = new Insets(5, 5, 0, 5);
		panel_1.add(btnStudentReport, gbc_btnStudentReport);
		btnStudentReport.setBounds(353, 7, 57, 23);
		
		panel_2 = new JPanel();
		GridBagConstraints gbc_panel_2 = new GridBagConstraints();
		gbc_panel_2.insets = new Insets(30, 0, 0, 0);
		gbc_panel_2.fill = GridBagConstraints.BOTH;
		gbc_panel_2.gridx = 0;
		gbc_panel_2.gridy = 4;
		gbc_panel_2.gridwidth = 3;
		panel.add(panel_2, gbc_panel_2);
		panel_2.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
		
		btnBack = new JButton("Back", new ImageIcon(ReportPrincipalUI.class.getResource("/aes/client/images/back.png")));
		btnBack.addActionListener(this); 
		GridBagConstraints gbc_btnBack = new GridBagConstraints();
		gbc_btnBack.insets = new Insets(5, 10, 0, 5);
		panel_2.add(btnBack, gbc_btnBack);
		btnBack.setBounds(353, 7, 57, 23);
		
	}

	/**
	 * Buttons click event handler
	 */
	@SuppressWarnings("static-access")
	@Override
	public void actionPerformed(ActionEvent e) {
		if (e.getSource().equals(btnBack)) {
			ui.SetContent(ui.MAIN_SCREEN);
		}
		else if (e.getSource().equals(btnStudentReport)) {
			ui.SetContent(ui.PRINCIPAL_STUDENT_REPORT_SCREEN);
		}
		else if (e.getSource().equals(btnTeacherReport)) {
			ui.SetContent(ui.PRINCIPAL_TEACHER_REPORT_SCREEN);
		}
		else if (e.getSource().equals(btnCourseReport)) {
			ui.SetContent(ui.PRINCIPAL_COURSE_REPORT_SCREEN);
		}
		
	}
	

}
